package com.example.rocketmq.demo.consumer;

import com.example.rocketmq.demo.config.RocketMQConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 基于注解方式的标签过滤消息消费者
 */
@Slf4j
@Component
@RocketMQMessageListener(
        topic = RocketMQConstant.TOPIC_FILTER,
        consumerGroup = "annotation-tag-filter-consumer-group",
        selectorType = SelectorType.TAG,
        selectorExpression = RocketMQConstant.TAG_FILTER_A + " || " + RocketMQConstant.TAG_FILTER_B // 只消费TAG_FILTER_A和TAG_FILTER_B标签的消息
)
public class AnnotationTagFilterConsumer implements RocketMQListener<String> {

    @Override
    public void onMessage(String message) {
        log.info("注解方式-接收到标签过滤消息: {}", message);
    }
}